<template>
  <div class="hot">
    <div class="tittle">热门推荐</div>
    <div class="hot-box" v-for="item of list" :key="item.id" ref="key">
      <img class="hot-img" :src="item.imgUrl" alt />
      <div class="hot-text">
        <el-tag type="success" class="hotsearch" @click="hotClickTo" v-model="searchId">查看详情</el-tag>
        <h2 class="hot-tittle">{{item.desc}}</h2>
        <h1 class="hot-name">{{item.title}}</h1>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "HomeHot",
  data() {
    return {
      searchId: this.key
    };
  },
  props: {
    list: Array
  },
  methods: {
    hotClickTo(e) {
    //   console.log(
    //     e.currentTarget.parentElement.parentElement.firstElementChild.src
    //   );
    //   console.log(e.currentTarget.nextElementSibling.innerHTML);
    //   console.log(
    //     e.currentTarget.nextElementSibling.nextElementSibling.innerHTML
    //   );
      const imgUrl =
        e.currentTarget.parentElement.parentElement.firstElementChild.src;
      const desc = e.currentTarget.nextElementSibling.innerHTML;
      const title =
        e.currentTarget.nextElementSibling.nextElementSibling.innerHTML;
        console.log(imgUrl,desc,title)
      this.$router.push({
        path: "/detail",
        query: {
            imgUrl:imgUrl,
            desc:desc,
            title:title
        }
      });
    }
  }
};
</script>

<style scoped>
.tittle {
  width: 100%;
  background: #ccc;
  font-size: 0.15rem;
  color: #fff;
  padding-left: 0.1rem;
  box-sizing: border-box;
  padding-bottom: 0.05rem;
}
.hot-box {
  display: flex;
  border-bottom: 0.001rem solid #ccc;
}
.hot-img {
  width: 1rem;
  padding: 0.1rem;
}
.hot-text {
  padding: 0.1rem;
  display: flex;
  flex-direction: column-reverse;
}
.hot-name {
  font-size: 0.2rem;
  padding-bottom: 0.1rem;
}
.hot-tittle {
  font-size: 0.15rem;
  padding-bottom: 0.05rem;
}
.hotsearch {
  width: 1rem;
}
</style>